package com.mission.scorepractice

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProviders
import com.mission.scorepractice.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    private val activityMainBinding: ActivityMainBinding by lazy {
        val binding= DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
        binding
    }

    private val viewModel: MyViewModel by lazy {
        val viewModel = ViewModelProviders.of(this).get(MyViewModel::class.java)
        viewModel
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
//        activityMainBinding =
//            DataBindingUtil.setContentView<ActivityMainBinding>(this, R.layout.activity_main)
//        viewModel = ViewModelProviders.of(this).get(MyViewModel::class.java)
        activityMainBinding.viewModelData = viewModel
        activityMainBinding.lifecycleOwner = this@MainActivity
    }
}